package com.qiaofang.constant;

import org.apache.commons.compress.utils.Lists;

import java.util.List;

/**
 *
 */
public enum WxModelTemplateEnum {

    REPORT_CHECK_TEMPLATE_ID("报备审核提醒", 1, 1),
    REPORT_SUCCESS_TEMPLATE_ID("报备成功提醒", 2, 1),
    REPORT_APPEAL_TEMPLATE_ID("报备申诉提醒", 4, 1),

    REPORT_REJECT_TEMPLATE_ID("报备驳回提醒", 3, 3),

    VISIT_SUCCESS_TEMPLATE_ID("到访成功", 5, 2),
    PAY_DEPOSIT_SUCCESS_TEMPLATE_ID("认筹成功提醒", 6, 2),
    SUBSCRIBE_SUCCESS_TEMPLATE_ID("认购成功提醒", 7, 2),
    SIGN_TEMPLATE_ID("签约提醒", 8, 2),
    DEAL_FAIL_TEMPLATE_ID("交易失败提醒", 9, 2),
    VISIT_CHECK_TEMPLATE_ID("提醒到访审核", 12, 2),

    PREMISES_SHELVE_TEMPLATE_ID("楼盘上架提醒", 10, 4),
    PREMISES_UNSHELVE_TEMPLATE_ID("楼盘下架提醒", 11, 4),

    ;

    /**
     * 模板名称
     */
    private String name;

    /**
     * 模板值
     */
    private Integer type;

    /**
     * 对应模板id
     */
    private Integer modelId;

    public String getName() {
        return name;
    }

    public Integer getType() {
        return type;
    }

    public Integer getModelId() {
        return modelId;
    }

    WxModelTemplateEnum(String name, Integer type, Integer modelId) {
        this.name = name;
        this.type = type;
        this.modelId = modelId;
    }

    public static List<WxModelTemplateEnum> listModelByModelId(Integer modelId) {
        List<WxModelTemplateEnum> list = Lists.newArrayList();
        for (WxModelTemplateEnum value : WxModelTemplateEnum.values()) {
            if (value.modelId.equals(modelId)) {
                list.add(value);
            }
        }
        return list;
    }

    public static List<Integer> listTypeByModelId(Integer modelId) {
        List<Integer> list = Lists.newArrayList();
        List<WxModelTemplateEnum> wxModelTemplates = listModelByModelId(modelId);
        if (wxModelTemplates != null) {
            for (WxModelTemplateEnum wxModelTemplate : wxModelTemplates) {
                list.add(wxModelTemplate.type);
            }
        }
        return list;
    }

}
